#include <Stepper.h>

/*内部齿轮旋转的步数*/
const float STEPS_PER_REV = 32;

/*齿轮减速量*/
const float GEAR_RED = 64;

/*每齿轮输出旋转的步数*/
const float STEPS_PER_OUT_REV = STEPS_PER_REV * GEAR_RED;

/*所需步骤数*/
int StepsRequired;

/*使用的是8，9，10，11引脚*/
Stepper steppermotor(STEPS_PER_REV,8,9,10,11);

void setup()
{
}

void loop()
{
  /*设置步进电机的速度为1*/
  steppermotor.setSpeed(10);
  /*电机转动的步数*/
  StepsRequired = 4;
  /*让步进电机转动StepsRequired步*/
  steppermotor.step(StepsRequired);
  delay(2000);

  /*计算转动半圈所需的步数*/
  StepsRequired = STEPS_PER_OUT_REV / 2;
  steppermotor.setSpeed(200);
  steppermotor.step(StepsRequired);
  delay(1000);

  /* 再次计算转动半圈所需的步数*/
  StepsRequired = STEPS_PER_OUT_REV / 2;
  steppermotor.setSpeed(1400);
  steppermotor.step(StepsRequired);
  delay(2000);
  
}
